<%-- 
    Document   : viewAvailabe
    Created on : Dec 17, 2009, 8:43:18 PM
    Author     : Administrator
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib  prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib  prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<table border="1">
    <tr>
        <th colspan="3">Available: ${product.name}</th>
    </tr>
    <tr>
        <th>Purchased Date</th>
        <th>Quantity</th>
        <th>Cost/${product.unit}</th>
    </tr>
    <c:set var="totalUnits" scope="request" value="0"/>
    <c:set var="totalCost" scope="request" value="0"/>
    <c:forEach var="avail" items="${availables}">
        <c:set var="totalUnits" scope="request" value="${totalUnits+avail.availableUnits}"/>
        <c:set var="totalCost" scope="request" value="${totalCost+avail.availableUnits * avail.cost}"/>
        <tr>
            <td><fmt:formatDate pattern="MMM d, yyyy" value="${avail.purchasedDate}"/></td>
            <td>${avail.availableUnits}</td>
            <td>${avail.cost} VND</td>
        </tr>
    </c:forEach>
    <tr><th colspan="3">Total</th></tr>
    <tr><th></th><th>Unit</th><th>Cost</th></tr>
    <tr><th></th><td>${totalUnits}</td><td>${totalCost} VND</td></tr>
</table>
